import json

import scrapy


class PostSpider(scrapy.Spider):
    name = "post"
    allowed_domains = ["fanyi.baidu.com"]
    # start_urls = ["https://fanyi.baidu.com/sug"]
    #
    # def parse(self, response):
    #     pass
    def start_requests(self):
        url = 'https://fanyi.baidu.com/sug'
        data = {
            'kw':'爱情'
        }
        yield scrapy.FormRequest(url=url,formdata=data,method='POST',callback=self.response_handle)

    def response_handle(self,response):
        content = response.text
        obj = json.loads(content)
        print(obj)




